package com.jp.knowledge.view;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;

import com.jp.knowledge.R;

/**
 * Created by jiayen on 16/11/3.
 *
 * 点布局由于   viewPager滑动指示
 */

public class DotLayout extends LinearLayout {
    private Context mContext;
    public DotLayout(Context context) {
        this(context,null);
    }

    public DotLayout(Context context, AttributeSet attrs) {
        this(context, attrs,0);
    }

    public DotLayout(Context context, AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        this.mContext=context;
        initView();
    }

    /**
     * 初始化view
     */
    private void initView() {

    }

    /**
     * 外部调用初始化
     * @param size
     */
    public void initView(int size){
        this.removeAllViews();
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(20,20);
        params.leftMargin=10;
        for (int i = 0; i <size ; i++) {
            View view = new View(mContext);
            view.setBackgroundResource(R.drawable.dot_com);
            this.addView(view);
            view.setLayoutParams(params);
        }
    }
}
